/*
 * 基于artDialog的扩展效果
 * @author liu
 */

window.artDialogExt = {
	skin:'green-dialog' //设置弹窗的默认皮肤
};
/*
 * loading 效果 
 * type：1 带遮层（默认） 2 不带遮层   
 * delay: 显示时间 多少毫秒后自动关闭 单位毫秒
 */
function loadingDialog(type,delay){
	var d = dialog({
		id: 'loading-dialog',
		skin: artDialogExt.skin,
		fixed: true
	});
	if (type == 2) {
		 d.show();
	}else{
		 d.showModal();
	}
	//设置自动关闭时间
	if(delay){
		setTimeout(function () {
			if(dialog.get('loading-dialog') != undefined){
				d.close().remove();
			}
		}, delay);
	}
}
//loading 效果关闭
function loadingDialogClose(){
	dialog({id: 'loading-dialog'}).close().remove();
}

//alert 效果
function alertDialog(msg,icon,type,delay,callback){
	var icon = icon?icon:'warning';
	var d = dialog({
		id: 'alert-dialog',
		title: '系统提示',
		skin: artDialogExt.skin,
		content: '<div class="alert-dialog alert-dialog-'+icon+'">'+msg+'</div>',
		fixed: true
	});
	if (type == 2) {
		 d.show();
	}else{
		 d.showModal();
	}
	delay = delay?delay:3000;
	if(delay){
		setTimeout(function () {
			if(dialog.get('alert-dialog') != undefined){
				d.close().remove();
			}
			if(callback instanceof Function){
					callback();
			}
		}, delay);
	}
}

//loading 效果关闭
function alertDialogClose(){
	dialog({id: 'alert-dialog'}).close().remove();
}

